#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/CashFlow.h>
#pragma unmanaged 
#include <ql\experimental\commodities\commoditycashflow.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Experimental { namespace Commodities {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ICommodityCashFlow
	public ref class CCommodityCashFlow  : 
            public CCashFlow,
            public Cephei::QL::Experimental::Commodities::ICommodityCashFlow
	{
	protected: 
		boost::shared_ptr<QuantLib::CommodityCashFlow>* _ppCommodityCashFlow;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CommodityCashFlow>* _phCommodityCashFlow;
#endif
		Object^ _CommodityCashFlowOwner;     // reference to object that manages the storage for this object
	internal:
		CCommodityCashFlow (DateTime date, Cephei::QL::IMoney^ discountedAmount, Cephei::QL::IMoney^ undiscountedAmount, Cephei::QL::IMoney^ discountedPaymentAmount, Cephei::QL::IMoney^ undiscountedPaymentAmount, Double discountFactor, Double paymentDiscountFactor, Boolean finalized);
        CCommodityCashFlow (boost::shared_ptr<QuantLib::CommodityCashFlow>& childNative, Object^ owner);
        CCommodityCashFlow (QuantLib::CommodityCashFlow& childNative, Object^ owner);
        CCommodityCashFlow (CCommodityCashFlow^ copy);
        CCommodityCashFlow (PLATFORM::Type^ t);
#ifdef STRUCT
        CCommodityCashFlow (QuantLib::CommodityCashFlow childNative);
#endif       
#ifdef HANDLE
		CCommodityCashFlow (QuantLib::Handle<QuantLib::CommodityCashFlow>& childNative, Object^ owner);
		CCommodityCashFlow (QuantLib::Handle<QuantLib::CommodityCashFlow> childNative);
#endif
		virtual ~CCommodityCashFlow ();
		!CCommodityCashFlow ();

	internal:
		QuantLib::CommodityCashFlow& GetReference ();
		boost::shared_ptr<QuantLib::CommodityCashFlow>& GetShared ();
		QuantLib::CommodityCashFlow* GetPointer ();
        void SetCommodityCashFlow (boost::shared_ptr<QuantLib::CommodityCashFlow> native)
        {
            if (_ppCommodityCashFlow != NULL)
                delete _ppCommodityCashFlow;
            _ppCommodityCashFlow = new boost::shared_ptr<QuantLib::CommodityCashFlow> (native);
            SetCashFlow (boost::dynamic_pointer_cast<QuantLib::CashFlow> (*_ppCommodityCashFlow));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CommodityCashFlow>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Double Amount 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::ICurrency^ Currency 
        {
		    virtual Cephei::QL::ICurrency^ get () ;
        }
        property DateTime Date 
        {
		    virtual DateTime get () ;
        }
        property Cephei::QL::IMoney^ DiscountedAmount 
        {
		    virtual Cephei::QL::IMoney^ get () ;
        }
        property Cephei::QL::IMoney^ DiscountedPaymentAmount 
        {
		    virtual Cephei::QL::IMoney^ get () ;
        }
        property Double DiscountFactor 
        {
		    virtual Double get () ;
        }
        property Boolean Finalized 
        {
		    virtual Boolean get () ;
        }
        property Double PaymentDiscountFactor 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::IMoney^ UndiscountedAmount 
        {
		    virtual Cephei::QL::IMoney^ get () ;
        }
        property Cephei::QL::IMoney^ UndiscountedPaymentAmount 
        {
		    virtual Cephei::QL::IMoney^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Experimental::Commodities::ICommodityCashFlow^>::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Commodities::ICommodityCashFlow::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Commodities::ICommodityCashFlow_Factory::typeid)]
	public ref class CCommodityCashFlow_Factory sealed : public ICommodityCashFlow_Factory
	{
	public:
        virtual ICommodityCashFlow^ Create (DateTime date, Cephei::QL::IMoney^ discountedAmount, Cephei::QL::IMoney^ undiscountedAmount, Cephei::QL::IMoney^ discountedPaymentAmount, Cephei::QL::IMoney^ undiscountedPaymentAmount, Double discountFactor, Double paymentDiscountFactor, Boolean finalized);
    };
   
/*Cephei*/ } /*QL*/ } /*Experimental*/ } /*Commodities */}
